<html>
    <body style="background: url(images/background.jpg);">
        <?php
            require 'config/dataSource.php';
            session_start();
        ?>
        <div>
    <h1><a href="forumIndex.php?<?php echo htmlspecialchars(SID); ?>">Return to Forum Index</a></h1>
    <h1><a href="createTopic.php?<?php echo htmlspecialchars(SID); ?>">Create a Topic</a></h1>
        </div>
        
        <div>
            <table border="2" bgcolor="#FFFFCC">
                <tr bgcolor="E8E8E8">
                    <th>ID</th>
                    <th>Topic Name</th>
                    <th>Owner</th>
                    <th>Created On</th>
                    <th># Replies</th>
                    <th>Last User Posted</th>
                    <th>Last Reply Date</th>
                </tr>
                <?php
                    $queryResult = mysql_query("SELECT * FROM topic");         
                    while ($row = mysql_fetch_array($queryResult)) {
                    $temp1 = $row['lastUpdatedBy'];
                    $temp2 = mysql_query("SELECT username FROM user, topic WHERE ".$temp1."=id"); 
                    $temp3 = mysql_fetch_assoc($temp3);
                    $temp4 = $row['owner'];
                    $temp5 = mysql_query("SELECT username FROM user, topic WHERE ".$temp4."=id");
                    $temp6 = mysql_fetch_assoc($temp5);
                    print("<tr>");
                    print("<td>". $row['tid']. "</td>");
                    print("<td>". $row['topicTitle']. "</td>");
                    print("<td>".$temp6['username']."</td>");
                    print("<td>". $row['dateCreated']. "</td>");
                    print("<td>". $row['numberOfReplies']. "</td>");
                    print("<td>". $temp3['username']. "</td>");
                    print("<td>". $row['dateUpdated']. "</td>");
                    print("</tr>");
                    }
                ?>
            </table>
            
        </div>
        
         <div>
    <h1><a href="forumIndex.php?<?php echo htmlspecialchars(SID); ?>">Return to Forum Index</a></h1>
    <h1><a href="createTopic.php?<?php echo htmlspecialchars(SID); ?>">Create a Topic</a></h1>
        </div>
    </body>
</html>